using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using BLL;
using BLL.Impl;

namespace WebUI.Admin.Func
{
    public partial class Func_List : BasicPage
    {

        private IAdminManager adminManager;
        protected void Page_Load(object sender, EventArgs e)
        {
            adminManager = BLLFactory.CreateAdminManager();
            if (!IsPostBack)
            {
                Display();
            }
        }

        private void Display()
        {
            this.grvFuncList.DataSource = adminManager.ListFunc();
            this.grvFuncList.DataKeyNames = new string[] { "FuncSN" };
            this.grvFuncList.DataBind();
        }

        protected void grvFuncList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Model.Func func = new Model.Func();
            func.FuncSN = Int32.Parse(this.grvFuncList.DataKeys[e.RowIndex].Value.ToString());
            adminManager.DelectFunc(func);
            Display();
        }

        protected void grvFuncList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.grvFuncList.PageIndex = e.NewPageIndex;
            Display();
        }
    }
}
